package com.lanou.web.controller;

import com.lanou.service.SearchService;
import com.lanou.utils.ShiHuiResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created by QuChao on 2018/12/1
 */
@RestController
@RequestMapping("/goods")
public class SearchController {
    @Autowired
    private SearchService searchService;

    @ApiOperation("搜索")
    @GetMapping("/search")
    public Map<String, Object> search(@RequestParam(value = "key", defaultValue = "精选") String key,
                                      @RequestParam(value = "page", defaultValue = "1") Integer page,
                                      @RequestParam(value = "size", defaultValue = "20") Integer size) {
        Map<String, Object> map = searchService.search(key, page, size);
        return ShiHuiResult.ok(map);
    }
}
